// Include libraries
#include <vector.h>

// Include game engine
#include "../../game_engine/game_engine.h"

// Enumerators
	// Tilesets
	enum Tileset
	{
		TILESET_TEST
	};

/** @brief Clears a bounding box
  *
  * @param boundingBox bounding box to be cleared (that is, all values set to zero)
  */
void clearBoundingBox(BoundingBox* boundingBox)
{
	boundingBox->rectEnabled=false;
	boundingBox->rectLeft=0;
	boundingBox->rectTop=0;
	boundingBox->rectWidth=0;
	boundingBox->rectHeight=0;
	boundingBox->slopeEnabled=false;
	boundingBox->slopeLeft=0;
	boundingBox->slopeTop=0;
	boundingBox->slopeWidth=0;
	boundingBox->slopeHeight=0;
}

/** @brief Sets tileset specifications and tileset for a game engine
  *
  * @param gameEngine pointer to the game engine in question
  * @param tempSurface NULL pointer. You are responsilbe for freeing this surface.
  * @param tileset the tileset to be set
  *
  * @return a vector of bounding boxes. You are resposible for freeing them and destroying the vector.
  */
vector<BoundingBox*> setTilesetSpecs(GameEngine* gameEngine, SDL_Surface* nullSurface, Tileset tileset)
{
	// Vector of bounding boxes
	vector<BoundingBox*> boundingBoxes;

	// Set test tileset specs
	if (tileset==TILESET_TEST)
	{
		// Add bounding boxes
			// Temporary bounding box pointer
			BoundingBox* tempBoundingBox;

			// Create bounding boxes
				// 1
					// Allocate memory
					tempBoundingBox=(BoundingBox*) malloc(sizeof(BoundingBox));

					// Set values
					clearBoundingBox(tempBoundingBox);
					tempBoundingBox->rectEnabled=true;
					tempBoundingBox->rectLeft=0;
					tempBoundingBox->rectTop=0;
					tempBoundingBox->rectWidth=32;
					tempBoundingBox->rectHeight=32;

					// Add to vector
					boundingBoxes.push_back(tempBoundingBox);

				// 2
					// Allocate memory
					tempBoundingBox=(BoundingBox*) malloc(sizeof(BoundingBox));

					// Set values
					clearBoundingBox(tempBoundingBox);
					tempBoundingBox->rectEnabled=true;
					tempBoundingBox->rectLeft=0;
					tempBoundingBox->rectTop=0;
					tempBoundingBox->rectWidth=64;
					tempBoundingBox->rectHeight=32;

					// Add to vector
					boundingBoxes.push_back(tempBoundingBox);

		// Set game engine tileset
		nullSurface=gfx_loadImage("gfx/tileset/test/tileset_test.png");
		gameEngine->setTileset(nullSurface);

		// Add terrain parts
		gameEngine->addTerrainPartSpecs(0, 0, 32, 32, boundingBoxes[0]);
		gameEngine->addTerrainPartSpecs(32, 0, 32, 32, boundingBoxes[0]);
		gameEngine->addTerrainPartSpecs(0, 32, 64, 32, boundingBoxes[1]);
	}

	// Return
	return boundingBoxes;
}

